#include "Person_lib.h"
#include "Student_lib.h"
#include "Lecturer_lib.h"
#include "Subject_lib.h"
#include "Course_lib.h"
int main(){
    string key;
    short c=0,c1=0,c2=0,c3=0,c4=0,c5=0;
    int i,j;
    cout<<"Welcome! \n";

while (c!=6){
    cout<<"                       *          *          *                   \n";
    cout<<"Menu: \n";
    cout<<"1.Student \n";
    cout<<"2.Lecturer \n";
    cout<<"3.Subject \n";
    cout<<"4.Course \n";
    cout<<"5.Registration \n";
    cout<<"6.Quit \n";
    cout<<"Please choose function:\n";
    cin>>c;
    system("cls");

switch (c){
case 1:{
    Student stu[100];
    j=0;
    ReadStudent("student.txt",stu,j);
    WriteStudent("studentout.txt",stu,j);
    cout<<"1.Print list on screen\n";
    cout<<"2.Find by name\n";
    cout<<"3.Find by classname\n";
    cout<<"4.Find by year\n";

    cin>>c1;
    if (c1!=1)
    cout<<"Enter search key: \n";

    switch (c1)
        {
            case 1:{
                for (i = 0; i < j; i++){
                        stu[i].Show();
            }
             break;
            }
            case 2:{
            cin>>key;
            Search_by_name(key,"student.txt");
            break;
            }
            case 3:{
            cin>>key;
            Search_by_classname(key,"student.txt");
            break;
            }
            case 4:{
            int year;
            cin>>year;
            Search_by_year(year,"student.txt");
            break;
            }
        }
    break;
}

case 2:{
    Lecturer lec[25];
    j=0;
    ReadLecturer("lecturer.txt",lec,j);
    WriteLecturer("lecturerout.txt",lec,j);
    cout<<"1.Print list on screen\n";
    cout<<"2.Find by ID\n";
    cin>>c2;
    if (c2!=1)
    cout<<"Enter search key: \n";

    switch (c2)
        {
            case 1:{

                for (i = 0; i < j; i++){
                        lec[i].Show();
             }
             break;
            }
            case 2:{
            break;
            }
        }
    break;
}

case 3:{
    Subject sub[50];
    j=0;
    ReadSubject("subject.txt",sub,j);
    WriteSubject("subjectout.txt",sub,j);
    cout<<"1.Print list on screen\n";
    cout<<"2.Find by Presub\n";
    cin>>c3;
    if (c3!=1)
    cout<<"Enter search key: \n";

    switch (c3)
        {
            case 1:{
                for (i = 0; i < j; i++){
                        sub[i].Show();
             }
             break;
             }
             case 2:{
                string pretemp;
                cin>>pretemp;
                Search_by_Presub(pretemp, "subject.txt", j);
             break;
             }
        }
    break;
}
case 4:{
    cout<<"1.Print on screen\n";
    cout<<"2.Search course\n";
    cout<<"3.Check conflict\n";
    cin>>c4;

    j=0;
    Course cou[100];
    ReadCourse("Course.txt",cou,j);
    switch (c4){
        case 3:{

    CheckConflictLecturer(cou, j);
    CheckConflictRoom(cou,j);
    }

}
    break;
}

case 5:{
    cin>>c4;
    switch (c4)
    {
        case 1:{
        }
        case 2:{
        }
        case 3:{
        }
    }
    break;
}

case 6:{
    break;
}

default:{
    cout<<"Function not found. Try again:\n";
    break;
}

}

}
    return 0;
}
